package com.zdp.controller;

import com.zdp.grace.result.GraceJSONResult;
import com.zdp.utils.MinioOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author sesshomaru
 * @date 2021/5/25
 */
@RestController
public class HelloController {

    @Autowired
    private MinioOperator minio;

    @PostMapping("/upload")
    public GraceJSONResult upload(@RequestParam("file") MultipartFile file) throws IOException {
        return GraceJSONResult.ok(minio.uploadToMinio("test", "testimg.jpg", file.getInputStream()));
    }
}
